<%@ taglib uri="/WEB-INF/myfaces_html.tld" 	prefix="h" %>
<%@ taglib uri="/WEB-INF/myfaces_core.tld" 	prefix="f" %>
<%@ taglib uri="/WEB-INF/tomahawk.tld"     	prefix="t" %>
<%@ page import="java.util.ArrayList" %>
<%@ taglib uri="/WEB-INF/myfaces_sandbox.tld"   prefix="s" %>

<%
    it.azienda.moretti.modello.BeanUtente utente = (it.azienda.moretti.modello.BeanUtente) session.getAttribute("login");
%>
<f:view>
    <jsp:include page="/intestazione.jsp">
        <jsp:param name="titolo" value="Gestione Utente"/>
    </jsp:include>
    <jsp:include page="/menu.jsp"/>
    <script language="javascript" src="./script/popup_full_center.js"></script>

    <t:saveState value="#{beanUtente}"/>

    <br />  
    <table class="find" style="border: 2pt solid white; margin-bottom: -10px">
        <hr />
        <tr>  
            <td class="intestazionePagina" align="center">
                <strong><t:outputLabel for="ricerca" value="PROFILO" /></strong></td>                        
        </tr>

    </table>

    <h:form binding="#{dettaglioUtente.form}" id="formLookup">    
        <t:saveState value="#{beanUtente}"/>

        <br />  
        <br />  <table class="dettaglio" >
            <tbody> 

                <%if (utente.getBeanRuolo().getSigla().equals("ADM")) {%>
                <tr>                   
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="email" value="Email (*)"/></strong></td>
                    <td><t:inputText id="email" value="#{beanUtente.email}" size="20" maxlength="20" styleClass="dettaglio_InputText" required="true" />
                        <br/>
                        <h:message style="color: red" for="email" showDetail="true" showSummary="false" />
                    </td>
                </tr>  
                <%} else {%>
                <tr>                   
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="email" value="Email (*)"/></strong></td>
                    <td><t:inputText id="email" value="#{beanUtente.email}" size="20" maxlength="20" styleClass="dettaglio_InputText" required="true" disabled="true"/>
                        <br/>
                        <h:message style="color: red" for="email" showDetail="true" showSummary="false" />
                    </td>
                </tr>  
                <%}%>

                <tr>                   
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="password" value="Password (*)"/></strong></td>
                    <td><t:inputSecret id="password" value="#{beanUtente.password}" size="20" maxlength="20" styleClass="dettaglio_InputText" disabled="true"/>
                        <br/>
                        <h:message style="color: red" for="password" showDetail="true" showSummary="false" />
                    </td>
                </tr>  


                <tr>                   
                    <td colspan="4">
                        <hr width="90%"></td>
                </tr> 

                <tr>                   
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="cognome" value="Cognome"/></strong></td>
                    <td><t:inputText id="cognome" value="#{beanUtente.cognome}" size="30" maxlength="30" styleClass="dettaglio_InputText" onchange="this.value=this.value.toUpperCase()" required="true"/>
                        <br/>
                        <h:message style="color: red" for="cognome" showDetail="true" showSummary="false" />
                    </td>
                </tr>   

                <tr>     
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="nome" value="Nome"/></strong></td>
                    <td><t:inputText id="nome" value="#{beanUtente.nome}" size="30" maxlength="30" styleClass="dettaglio_InputText" onchange="this.value=this.value.toUpperCase()" required="true"/>
                        <br/>
                        <h:message style="color: red" for="nome" showDetail="true" showSummary="false" />
                    </td>
                </tr>   

                <tr> 
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="dataNascita" value="Data Nascita"/></strong></td>
                    <td><h:outputText value=" (gg/mm/aaaa)" style="font-size:6.5pt"/>
                        <br/>
                        <t:inputCalendar id="dataNascita" renderAsPopup="true" renderPopupButtonAsImage="true" popupDateFormat="dd/MM/yyyy" size="10" styleClass="campoTesto" value="#{beanUtente.dataNascita}">
                            <f:convertDateTime pattern="dd/MM/yyyy" type="both" timeZone="Europe/Rome"/>
                        </t:inputCalendar>
                        <h:message style="color: red" for="dataNascita" showDetail="true" showSummary="false" />
                    </td>
                </tr>        

                <tr>                   
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="sesso" value="Sesso(*)"/></strong></td>
                    <td>
                        <t:selectOneMenu id="sesso" value="#{beanUtente.sesso}">
                            <f:selectItem itemValue="M" itemLabel="Maschio"/>
                            <f:selectItem itemValue="F" itemLabel="Femmina"/>
                        </t:selectOneMenu>  
                    </td>
                </tr>  

                <tr>
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="descrizioneComune_Nascita" value="Comune di Nascita" /></strong></td>
                    <td>
                        <h:selectOneMenu id="comuneNascita" value="#{beanUtente.idComuneNascita}"  style=" width:90%;">
                            <f:selectItems value="#{beanUtente.listaComuni}" />
                        </h:selectOneMenu> 
                    </td>              

                </tr>  

                <tr>     
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="codicefiscale" value="Codice fiscale"/></strong></td>
                    <td><t:inputText id="codicefiscale" value="#{beanUtente.codicefiscale}" size="30" maxlength="16" styleClass="dettaglio_InputText" onchange="this.value=this.value.toUpperCase()" required="true"/>
                        <br/>
                        <h:message style="color: red" for="codicefiscale" showDetail="true" showSummary="false" />
                    </td>
                </tr>   


                <tr>     
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="telefono" value="Telefono"/></strong></td>
                    <td><t:inputText id="telefono" value="#{beanUtente.telefono}" size="30" maxlength="30" styleClass="dettaglio_InputText" onchange="this.value=this.value.toUpperCase()" required="true"/>
                        <br/>
                        <h:message style="color: red" for="telefono" showDetail="true" showSummary="false" />
                    </td>
                </tr>   

                <tr>     
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="cellulare" value="Cellulare"/></strong></td>
                    <td><t:inputText id="cellulare" value="#{beanUtente.cellulare}" size="30" maxlength="16" styleClass="dettaglio_InputText" onchange="this.value=this.value.toUpperCase()" required="true"/>
                        <br/>
                        <h:message style="color: red" for="cellulare" showDetail="true" showSummary="false" />
                    </td>
                </tr>  

                <tr>
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="descrizioneComune_Residenza" value="Comune di Residenza" /></strong></td>
                    <td>
                        <h:selectOneMenu id="comuneResidenza" value="#{beanUtente.idComuneResidenza}"  style=" width:90%;">
                            <f:selectItems value="#{beanUtente.listaComuni}" />
                        </h:selectOneMenu> 
                    </td>              

                </tr>  

                <tr>                   
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="verificato" value="Verificato(*)"/></strong></td>
                    <td>
                        <t:selectOneMenu id="verificato" value="#{beanUtente.verificato}" disabled="true">
                            <f:selectItem itemValue="S" itemLabel="Si"/>
                            <f:selectItem itemValue="N" itemLabel="No"/>
                        </t:selectOneMenu>  
                    </td>
                </tr>          

                <tr>                   
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="attivo" value="Attivo(*)"/></strong></td>
                    <td>
                        <t:selectOneMenu id="attivo" value="#{beanUtente.attivo}" disabled="true">
                            <f:selectItem itemValue="S" itemLabel="Si"/>
                            <f:selectItem itemValue="N" itemLabel="No"/>
                        </t:selectOneMenu>  
                    </td>
                </tr>          

                <tr>
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="ruolo" value="Ruolo" /></strong></td>
                    <td>
                        <h:selectOneMenu id="ruolo" value="#{beanUtente.idRuolo}"  style=" width:90%;">
                            <f:selectItems value="#{beanUtente.listaRuolo}" />
                        </h:selectOneMenu> 
                    </td>              

                </tr>      

                <tr> 
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="dataRegistrazione" value="Data registrazione"/></strong></td>
                    <td><h:outputText value=" (gg/mm/aaaa)" style="font-size:6.5pt"/>
                        <br/>
                        <t:inputCalendar id="dataRegistrazione" renderAsPopup="true" renderPopupButtonAsImage="true" popupDateFormat="dd/MM/yyyy" size="10" styleClass="campoTesto" value="#{beanUtente.dataregistrazione}" disabled="true">
                            <f:convertDateTime pattern="dd/MM/yyyy" type="both" timeZone="Europe/Rome"/>
                        </t:inputCalendar>
                        <h:message style="color: red" for="dataRegistrazione" showDetail="true" showSummary="false" />
                    </td>
                </tr>        

                <tr>                   
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="percRicarico" value="% Ricarico"/></strong></td>
                    <td>
                        <t:inputText id="percRicarico" value="#{beanUtente.percRicarico}" size="10" maxlength="6" styleClass="dettaglio_InputText" style="text-align: right"  required="false" disabled="true">
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:inputText>
                        <h:message style="color: red" for="percRicarico" showDetail="true" showSummary="false" /></td>
                    </td>
                </tr>

        </table>
        <t:inputHidden value="#{beanUtente.id}"/>   
        <t:inputHidden value="#{beanUtente.password}"/>   

        <table bgcolor="#FFFFFF" width="750px">
            <tr>    
                <td>
                    <h:commandLink styleClass="commandLink_Style" dir="RTL" action="benvenuto" immediate="true">
                        <t:graphicImage url="/image/go-home.png" border="0"/>
                    </h:commandLink>              
                </td>   

                <td>
                    <t:commandLink action="#{dettaglioUtente.primo}"  rendered="#{beanUtente.id ne null && login.beanRuolo.sigla eq 'ADM'}">
                        <t:graphicImage url="image/primo.png" border="0" title="Vai al primo elemento"/>
                        <f:param name="bean" value="beanUtente"/>                        
                        <f:param name="id" value="#{beanUtente.id}"/>                 
                    </t:commandLink>
                </td>
                <td>
                    <t:commandLink action="#{dettaglioUtente.precedente}" rendered="#{beanUtente.id ne null && login.beanRuolo.sigla eq 'ADM'}">
                        <t:graphicImage url="image/indietro.png" border="0" title="Indietro"/>
                        <f:param name="bean" value="beanUtente"/>                        
                        <f:param name="id" value="#{beanUtente.id}"/>                 
                    </t:commandLink>
                </td>
                <td>
                    <t:commandLink action="#{dettaglioUtente.successivo}" rendered="#{beanUtente.id ne null && login.beanRuolo.sigla eq 'ADM'}">
                        <t:graphicImage url="image/avanti.png" border="0" title="Avanti"/>
                        <f:param name="bean" value="beanUtente"/>                        
                        <f:param name="id" value="#{beanUtente.id}"/>                 
                    </t:commandLink>
                </td>
                <td>
                    <t:commandLink action="#{dettaglioUtente.ultimo}" rendered="#{beanUtente.id ne null && login.beanRuolo.sigla eq 'ADM'}">
                        <t:graphicImage url="image/ultimo.png" border="0" title="Vai all'ultimo elemento"/>
                        <f:param name="bean" value="beanUtente"/>                        
                        <f:param name="id" value="#{beanUtente.id}"/>                 
                    </t:commandLink>
                </td>

                <td>
                    <h:commandLink dir="RTL" onmousedown="return confirmDelete(this);" title="cancella" action="#{dettaglioUtente.cancella}" rendered="#{beanUtente.id ne null && login.beanRuolo.sigla eq 'ADM'}">
                        <t:graphicImage url="image/stop.png" border="0" title="Cancella"/>
                        <f:param name="bean" value="beanUtente" />
                    </h:commandLink>                
                </td>      

                <td>
                    <h:commandLink dir="RTL" onmousedown="return confirmUpdate(this);" title="modifica" action="#{dettaglioUtente.modifica}" rendered="#{beanUtente.id ne null}">
                        <t:graphicImage url="image/salva.png" border="0" title="Salva modifiche"/>
                        <f:param name="bean" value="beanUtente" />
                    </h:commandLink>                
                </td>    

                <td>
                    <h:commandLink dir="RTL" onmousedown="return confirmSave(this);" title="salva inserimento" action="#{dettaglioUtente.inserisci}" rendered="#{beanUtente.id eq null && login.beanRuolo.sigla eq 'ADM'}">
                        <t:graphicImage url="image/salva.png" border="0" title="Salva inserimento"/>
                        <f:param name="bean" value="beanUtente" />
                    </h:commandLink>                
                </td>
                <td>
                    <h:commandLink dir="RTL" title="inserisce nuovo elemento" action="#{dettaglioUtente.inserisciDettaglio}" rendered="#{beanUtente.id ne null && login.beanRuolo.sigla eq 'ADM'}">
                        <t:graphicImage url="image/nuovo.png" border="0" title="Inserisci NUOVO"/>
                        <f:param name="bean" value="beanUtente" />
                    </h:commandLink>
                </td>
            </tr>
        </table>

    </h:form>

    <h:form id="erroriDataBase" rendered="false">
        <table><td align="left" class="messaggiErrore" height="2px">           
                <h:messages style="color: red" showDetail="true" showSummary="false"/>
            </td></table>
        </h:form>     

    <jsp:include page="/piePagina.jsp"/>      
</f:view>
